from fastapi import FastAPI
import httpx

app = FastAPI(title="每日经典语录服务")

@app.get("/quote")
def get_quote():
    """获取每日经典语录（真实API）"""
    url = "https://v1.hitokoto.cn/?encode=json"
    try:
        r = httpx.get(url, timeout=5)
        data = r.json()
        return {"hitokoto": data.get("hitokoto", "获取失败")}
    except Exception as e:
        return {"error": f"获取失败: {e}"}
